<?php #//v.3.3.0
#///////////////////////////////////////////////////////
#//  COPYRIGHT 2004 Phpauction.org ALL RIGHTS RESERVED//
#///////////////////////////////////////////////////////

require('./includes/config.inc.php');


$TIME = mktime(date("H")+$SETTINGS['timecorrection'],date("i"),date("s"),date("m"), date("d"),date("Y"));

$NOW = date("YmdHis",$TIME);


//* get ending soon auctions */
$TPL_ending_soon_value = "";
/* $query = "select retail,ends,id,title,current_high_bidder,current_bid,pict_url from PHPAUCTIONXL_auctions
         WHERE closed='0' AND
         suspended='0' AND ";
         $query .= "starts<=".$NOW."
         order by id LIMIT ".$SETTINGS['endingsoonnumber'];*/
         
         
         
         $query = "select retail,ends,id,title,current_high_bidder,current_bid,pict_url from PHPAUCTIONXL_auctions
         WHERE closed='0' AND
         suspended='0' AND ";
         $query .= "starts<=".$NOW."
         order by id LIMIT 0,100";
         
$result = mysql_query($query);
$num_auction = mysql_num_rows($result);

$jsenddate = "";

$jsenddate .= substr ($NOW, 4, 2);
$jsenddate .= "/";
$jsenddate .= substr ($NOW, 6, 2);
$jsenddate .= "/";
$jsenddate .= substr ($NOW, 0, 4);
$jsenddate .= " ";


     
if (substr ($NOW, 8, 2) > 12) {
$jsenddate .= substr ($NOW, 8, 2)-12;
$jsampm = "PM";
}
if (substr ($NOW, 8, 2) != 00){
if (substr ($NOW, 8, 2) < 12) {
$jsenddate .= substr ($NOW, 8, 2);
$jsampm = "AM";
}}
if (substr ($NOW, 8, 2) == 12) {
$jsenddate .= substr ($NOW, 8, 2);
$jsampm = "PM";
}
if (substr ($NOW, 8, 2) == 00) {
$jsenddate .= 12;
$jsampm = "AM";
}

$jsenddate .= ":";
$jsenddate .= substr ($NOW, 10, 2);
$jsenddate .= ":";
$jsenddate .= substr ($NOW, 12, 2);
$jsenddate .= " ";
$jsenddate .= $jsampm;
$jsenddate .= "|";

 
//* get ending soon auctions */
$TPL_ending_soon_value = "";
$query = "select retail,starts,id,title,current_high_bidder,current_bid,pict_url from PHPAUCTIONXL_auctions
         WHERE closed='0' AND
         suspended='0' AND ";
$query .= "starts>=".$NOW."
         ORDER BY starts ASC LIMIT 0,100";
 $result = mysql_query($query);
$num_auction = mysql_num_rows($result);



 $i = 0;
while($i < $num_auction) {

$title 	= mysql_result($result,$i,"title");
	$id 	= mysql_result($result,$i,"id");
	$starts 	= mysql_result($result,$i,"starts");
  $high_bidder 	= mysql_result($result,$i,"current_high_bidder");
	$high_bid 	= mysql_result($result,$i,"current_bid");
	$picture_url = mysql_result($result,$i,"pict_url");
	$retail  = mysql_result($result,$i,"retail");
	$nowt	= $TIME;

	$jsenddate .= "2";
$jsenddate .= "|";
$jsenddate .= substr ($starts, 4, 2);
$jsenddate .= "/";
$jsenddate .= substr ($starts, 6, 2);
$jsenddate .= "/";
$jsenddate .= substr ($starts, 0, 4);
$jsenddate .= " ";

     
if (substr ($starts, 8, 2) > 12) {
$jsenddate .= substr ($starts, 8, 2)-12;
$jsampm = "PM";
}
if (substr ($starts, 8, 2) != 00){
if (substr ($starts, 8, 2) < 12) {
$jsenddate .= substr ($starts, 8, 2);
$jsampm = "AM";
}}
if (substr ($starts, 8, 2) == 12) {
$jsenddate .= substr ($starts, 8, 2);
$jsampm = "PM";
}
if (substr ($starts, 8, 2) == 00) {
$jsenddate .= 12;
$jsampm = "AM";
}

$jsenddate .= ":";
$jsenddate .= substr ($starts, 10, 2);
$jsenddate .= ":";
$jsenddate .= substr ($starts, 12, 2);
$jsenddate .= " ";
$jsenddate .= $jsampm;
$jsenddate .= "|";
$jsenddate .= $title;
$jsenddate .= "|";
$jsenddate .= $id;
$jsenddate .= "|";
$jsenddate .= $picture_url;
$jsenddate .= "|";
$jsenddate .= print_money_nosymbol($retail);
$jsenddate .= "|";


$i++;
}










      $myFile2 = "cronfiles/get_time3.txt";
$fh = fopen($myFile2, 'w') or die("can't open file");
$stringData = $jsenddate;
fwrite($fh, $stringData);
fclose($fh);


       


    /*
    
     $ProcessState = 0;
     $PID = shell_exec("nohup unique.php > /dev/null & echo $!");
     exec("ps $PID", $ProcessState);
      echo $PID;
      
      
      echo $ProcessState;
     
      if ( count($ProcessState) >= 2 )
      {
                          echo $PID;
      echo $ProcessState;
      
     if(exec::is_running($PID)){
           exec("kill -KILL $PID");      
      }
     }
           
     */      
   
           
?> 